import 'dart:math';

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(new MaterialApp(
    home: Scaffold(
      appBar: AppBar(
        title: Text("GestureRecognizer"),
      ),
      body: HomeScreen(),
    ),
  ));
}

class HomeScreen extends StatefulWidget {
  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  TapGestureRecognizer _tapGestureRecognizer;
  DragGestureRecognizer _dragGestureRecognizer;
  ScaleGestureRecognizer _scaleGestureRecognizer;
  var _big = false;

  @override
  void initState() {
    super.initState();
    _tapGestureRecognizer = TapGestureRecognizer();
    _tapGestureRecognizer.onTapDown = (detail) {
      print("onTapDown");
    };
  }

  @override
  void dispose() {
    super.dispose();
    _tapGestureRecognizer.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        Container(
          child: Row(
            children: <Widget>[
              Text.rich(TextSpan(
                  text: "哈哈大方",
                  style: TextStyle(fontSize: _big ? 30 : 20),
                  recognizer: _tapGestureRecognizer
                    ..onTap = () {
                      setState(() {
                        _big = !_big;
                      });
                    })),
            ],
          ),
        ),
      ],
    );
  }
}
